<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="../core/include.inc.jsp"%>

<style>
    .pageFormContent p {
        width: 90%;
    }
</style>

<div class="pageContent">
    <form method="post" action="duty_add" class="pageForm required-validate duty_add"
          onsubmit="return validateCallback(this, dialogAjaxDone)">

        <div class="pageFormContent nowrap" layoutH="57">

            <p>
                <label>小区名称：</label>
                <select class="combox" name="blockId" id="blockId">
                    <option value="">全部小区</option>
                    <c:forEach var="item1" items="${blockList}">
                        <option value="${item1.id}">${item1.blockName}</option>
                    </c:forEach>
                </select>
            </p>

            <p>
                <label>物业座机：</label>
                <input type="text" name="telephone" id="telephone" class="required" />
            </p>

            <p>
                <label>值班人：</label>
                <input type="text" name="dutyer"  class="required" />
            </p>

            <p>
                <label>身份：</label>
                <input type="text" name="position"  class="required" />
            </p>

            <table width="100%">
                <tr class="text-normal">
                    <td>
                        <label>头像：</label>
                        <div class="image-logo">
                            <img src="${app:getLocalUrl() }/assets/ext/js/uploadify/add_img.png" class="imgList">
                            <input type="file" onchange="upload(0)" class="imgFile"/>
                        </div>
                        <input type="hidden" name="headImage" class="logo" value="" />
                    </td>
                </tr>
            </table>

            <p>
                <label>值班时间：</label>
                <input type="text" name="startTime"  class="date textInput valid required" datefmt="yyyy-MM-dd HH:mm:ss"/>

                <input type="text" name="endTime"  class="date textInput valid required" datefmt="yyyy-MM-dd HH:mm:ss"/>
                <%--<a class="inputDateButton" href="javascript:;">选择</a>--%>
            </p>

            <p>
                <label>备注：</label>
                <input type="text" name="remark"/>
            </p>


        </div>
        <div class="formBar">
            <ul>
                <li>
                    <div class="buttonActive">
                        <div class="buttonContent" style="text-align: center;">
                            <button type="submit">保存</button>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </form>
</div>

<script>

    // 设置图片地址
    function setImage(index,url) {
        $('.imgList').eq(index).attr('src',url);
        $('.logo').eq(index).val(url);
    }

    function upload(index) {
        uploadImage(index,$('.imgFile').eq(index).get(0).files[0]);
    }

    $(".duty_add select[name='blockId']").change(function () {
        var blockId = $("#blockId").val();
        $.ajax({
            type:"post",
            url:"get_phone",
            data:{"blockId":blockId},
            dataType:"json",
            success:function(data) {
                console.log(data);
                $("#telephone").val(data.telePhone);
            }
        })
    })

</script>